<?php
if (!defined('__COLA_DIR__')) exit;

/**
 * Widget_Metas_Category_Ucenter  
 * 
 * @author edikud
 * @package Widget
 * @copyright Copyright (c) 2019 Cola (http://www.mcooo.com)
 * @license GNU General Public License 2.0
 */
class Widget_Metas_Category_Ucenter extends Widget_Abstract_Metas
{

    /**
     * 执行函数
     *
     * @access public
     * @return void
     */
    public function execute()
    {
		$this->user->pass('editor');
        $this->stack = $this->widget('Widget_Metas_Category_List')->getCategories();
    }
	
    public function categoryList()
    {
        if ($this->have()) {
            $WidgetMenu = $this->widget('Widget_Menu');
			$Layout = new Layout();
			$Layout->header(array(
				$this->widget('Widget_Metas_Category_Edit')->operate(),
			    _t('名称'),
				_t('缩略名')
			));
			while ($this->next()){
			    $Layout->lists(array(
				    '<a class="cola-balloon" href="'.$this->options->ucenterUrl('posts?category=' . $this->mid, false).'">'.$this->contentsNum.'</a>&nbsp;&nbsp;<span class="text-muted">'.($this->level ? '&nbsp;&nbsp;&nbsp;&nbsp;|--':'') . str_repeat('--', $this->level>-1 ? $this->level : ''). '</span> <a href="' .$this->options->ucenterUrl('category?mid=' . $this->mid, false).'">'.$this->name.'</a>&nbsp;&nbsp;&nbsp;<a class="text-muted text-md" href="'.$this->permalink.'"><i class="ci-link"></i></a>',
					'<span class="text-muted text-md">' . $this->alias . '</span>'
				), array('data-mid'=>$this->mid));
			}
			$html = $Layout->render();

		} else {
			
			$html = '<h6>'._t('内容为空').'</h6>';
		}

		return $html;
	}
}

